﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ArduinoSketch.Core
{
    public partial class frmOutput : BaseFormContent, IOutputConsole
    {
        public frmOutput()
        {
            InitializeComponent();
            InvokeClearConsole = new DoClearConsole(ClearConsole);
            InvokeMessageInfo = new InvokeMessage(DoInvokeMessageInfo);
        }

        private void DoInvokeMessageInfo(string[] msg)
        {
            foreach (var strMsg in msg)
            {
                this.lstOutput.Items.Add(strMsg);
                if (this.lstOutput.SelectionMode == SelectionMode.One)
                {
                    this.lstOutput.SelectedIndex = this.lstOutput.Items.Count - 1;
                }
            }
            this.Show();
        }


        #region IOutputConsole Members

        public void ClearConsole()
        {
            this.lstOutput.Items.Clear();          
        }

        public DoClearConsole InvokeClearConsole{get; set;}

        public InvokeMessage InvokeMessageInfo { get; set; } 

        #endregion
    }
}
